package com.jeesite.modules.yzw.web;

import com.jeesite.modules.annotation.RepeatSubmit;
import com.jeesite.modules.yzw.service.OtsDataService;
import com.jeesite.modules.yzw.service.SyncIflytekService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

@Controller
public class OtsDataController {

    @Autowired
    private OtsDataService otsDataService;
    @Autowired
    private SyncIflytekService syncIflytekService;

    /**
     * 递归查询机构，并更新
     * @return
     */
    @RequestMapping(value = "findListOrg")
    @ResponseBody
    private String findListOrg(){
        String msg=otsDataService.findListOrg();
        //剔除已经无效的组织
        otsDataService.deleteOrg();
        return msg;
    }

    /**
     * 查询用户，并更新
     * @return
     */
    @RequestMapping(value = "findListUser")
    @ResponseBody
    private String findListUser(){
        String msg=otsDataService.findListUser();
        return msg;
    }


    /**
     * 全量同步组织机构
     * @return
     */
    @RequestMapping(value = "Org")
    @ResponseBody
    private String Org() throws Exception {
        syncIflytekService.queryDeptListAll();
        return "ok";
    }
    /**
     * 全量同步组织用户关系
     */
    @RequestMapping(value = "OrgUser")
    @ResponseBody
    private String OrgUser(){
        syncIflytekService.queryDeptUserListAll();
        return "ok";
    }
    /**
     * 全量同步用户
     */
    @RequestMapping(value = "User")
    @ResponseBody
    private String User(){
        syncIflytekService.queryUserListAll();
        return "ok";
    }

    /**
     * 反馈终止手动修改大于feedbackEndTime的feedback_status为11无需反馈,action表task_status为4已结束
     * @return
     */
    @RequestMapping("updateActionAndFeedback")
    @ResponseBody
    @RepeatSubmit
    public String updateActionAndFeedback() {
        otsDataService.updateActionAndFeedback();
        return "ok";
    }

    /**
     * 增量同步用户 test
     */
    @RequestMapping(value = "findTextUser")
    @ResponseBody
    private String findTextUser(){
        syncIflytekService.queryUserListByDate(null);
        return "ok";
    }
}
